<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>百分比padding</title>
    <style>
      body, ul {
        margin: 0;
        padding: 0;
      }
      ul li {
        list-style: none;
      }
      .box {
        overflow: hidden;
      }
      .list {
        width: calc(25% - 1.5rem / 4);
        float: left;
        margin-bottom: 0.5rem;
      }
      .list:not(:nth-child(4n + 1)) {
        margin-left: 0.5rem;
      }
      .cover {
        padding: 100% 100% 0 0;
        position: relative;
      }
      .cover img {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
    </style>
  </head>
  <body>
    <ul class="box">
      <li class="list">
        <div class="cover">
          <img src="./1.jpg" />
        </div>
      </li>
      <li class="list">
        <div class="cover">
          <img src="./2.jpg" />
        </div>
      </li>
      <li class="list">
        <div class="cover">
          <img src="./3.jpg" />
        </div>
      </li>
      <li class="list">
        <div class="cover">
          <img src="./4.png" />
        </div>
      </li>
    </ul>
  </body>
</html>
